<?php
/**
 * Author：小鱼
 * QQ:34734852
 * Wechat:34734852
 */
namespace Home\Controller;
use Think\Controller;

class ActionController extends Controller{
    private $table;
    private $where;
    private $order;
    function __construct(){
        parent::__construct();
        $this->assign('system',$this->systemInfo());
    }
    //查询数据
    protected function data($table,$where,$order,$limit=''){
        $this->table = $table;
        $this->where = $where ? $where : array();
        $this->order = $order ? $order :"";
        $shuju = M($this->table)->where($this->where)->order($this->order)->limit($limit)->select();
        return $shuju;
    }
    //单条数据查询
    protected function one_data($table,$where=''){
        if(!empty($table)){
        $shuju = M($table)->where($where)->find();
        }else{
            $this->error('数据表查询失败！');
        }
        return $shuju;
    }    
    /* 分页 */
    protected function fenye($table_name,$where=array(),$order='',$assign,$showpage,$num){
        $shuju = M($table_name);
        $count = $shuju->where($where)->count();
        $page = new \Think\Page($count,$num);
        $page->setConfig('theme',"<ul class='pagination'></li><li>%FIRST%</li><li>%UP_PAGE%</li><li>%LINK_PAGE%</li><li>%DOWN_PAGE%</li><li>%END%</li><li><a> %HEADER%  %NOW_PAGE%/%TOTAL_PAGE% 页</a></ul>");
        $show =$page->show();
        $data = $shuju->where($where)->order($order)->limit($page->firstRow.','.$page->listRows)->select();
        $this->assign($assign,$data);
        $this->assign($showpage,$show);
    }
    protected  function systemInfo(){
            $system = M('system');
            $data = $system->find();
            return $data;
    }
   protected function cuowu(){
        $this->display('Public/404');
    }
    public function  _empty(){
        $this->cuowu();
    }
}